package com.example.demo;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;
import java.time.LocalDate;
import java.util.List;

public interface UserReposoitory extends JpaRepository<User,Integer>{
    List<User> findByNameContaining(String name);

    @Query("select u from User u where u.birthDay = ?1")
    List<User> findByBirthDay(LocalDate birthDay);

    @Query(value = "select * from user where birth_day = :birthDay",nativeQuery = true)
    List<User> findByBirthDayNative(@Param("birthDay") String birthDay);

    @Modifying
    @Transactional
    @Query(value = "delete from User")
    int delete();
}
